/*
 * @Author: 可以清心
 * @Description: 
 * @Date: 2022-11-28 09:14:26
 * @LastEditTime: 2022-12-02 17:39:09
 */
export default {
    setStorage: function(passOrname, type){
        let key = btoa(type);
        let value = btoa(passOrname);
        localStorage.setItem(key, value);
    },
    getPassWord: function(){
        let key = btoa('password');
        
        return localStorage.getItem(key);
    },
    getUsername: function(){
        let key = btoa('username');

        return localStorage.getItem(key);
    },
    removeStorage: function(){
        localStorage.removeItem(btoa('username'));
        localStorage.removeItem(btoa('password'));
    },
    setModule: function(data){
        console.log(data);
        let result = {
            authModule: {},
            tenantModule: {}
        }

        result.authModule.tenantBlock = {
            token: data.token,
            oriToken: null
        }

        result.authModule.userInfo = {
            tenant: data.userDefaultTenant
        }

        Object.assign(result.authModule.userInfo, data.user || data.userInfo)

        if (data.userDefaultTenant && data.userDefaultTenant.tenantBasicInfo && data.userDefaultTenant.tenantBasicInfo.limitId) {
            result.tenantModule.xdaptenantversion = data.userDefaultTenant.tenantBasicInfo.limitId
        }

        result.tenantModule.currentOrg = data.userDefaultTenant || {}

        localStorage.setItem(`__vuex__local`, JSON.stringify({authModule: result.authModule}));
        sessionStorage.setItem('__vuex__session', JSON.stringify({tenantModule: result.tenantModule}));
        // console.log(data);
    }
}